package com.smedi.ismedi.personnel.api.feign;

import com.smedi.ismedi.personnel.api.dto.response.ProfileImageResponse;
import com.smedi.ismedi.personnel.api.dto.response.SignatureResponse;
import com.smedi.ismedi.personnel.api.dto.response.UploadPersonTemplateValidateResponse;
import com.smedi.ismedi.web.starter.common.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @Author: xulinjun
 * @Date: 2021-6-12 14:38
 */
@Api(tags = {"人员管理文件与定时接口"})
@FeignClient(name = "ismedi-personnel")
@RequestMapping(value = "/api/v1/personnel/public")
public interface RemotePersonAssistFeignApi {
    /**
     * 上传人员头像照片
     *
     * @param file
     * @return
     */
    @ApiOperation(httpMethod = "POST", value = "上传人员头像照片")
    @PostMapping(value = "/uploadProfileImage", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    ResponseData<String> postUploadProfileImage(@RequestPart("file") MultipartFile file);

    /**
     * 上传人员头像照片，并且不需要确认即可保存
     *
     * @param file
     * @return
     */
    @ApiOperation(httpMethod = "POST", value = "上传人员头像照片，并且不需要确认即可保存")
    @PostMapping(value = "/uploadProfileImageWithNoConfirm", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    ResponseData<Boolean> postUploadProfileImageWithNoConfirm(@RequestPart("file") MultipartFile file, @RequestParam("personId") Long personId);

    /**
     * 下载人员头像照片
     *
     * @param imageUUID
     */
    @ApiOperation(httpMethod = "GET", value = "下载人员头像照片")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "imageUUID", value = "照片id", dataType = "String", dataTypeClass = String.class)
    })
    @GetMapping(value = "/downloadProfileImage")
    ResponseData<ProfileImageResponse> getDownloadProfileImage(@RequestParam("imageUUID") String imageUUID);

    /**
     * 上传人员签章
     *
     * @param file
     * @return
     */
    @ApiOperation(httpMethod = "POST", value = "上传人员签章")
    @PostMapping(value = "/uploadSignature", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    ResponseData<String> postUploadSignature(@RequestPart("file") MultipartFile file);

    /**
     * 上传人员签章，并且不需要确认即可保存
     *
     * @param file
     * @return
     */
    @ApiOperation(httpMethod = "POST", value = "上传人员签章，并且不需要确认即可保存")
    @PostMapping(value = "/uploadSignatureWithNoConfirm", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    ResponseData<Boolean> postUploadSignatureWithNoConfirm(@RequestPart("file") MultipartFile file, @RequestParam("personId") Long personId);

    /**
     * 下载人员签章
     *
     * @param signatureUUID
     */
    @ApiOperation(httpMethod = "GET", value = "下载人员签章")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "signatureUUID", value = "签章id", dataType = "String", dataTypeClass = String.class)
    })
    @GetMapping(value = "/downloadSignature")
    ResponseData<SignatureResponse> getDownloadSignature(@RequestParam("signatureUUID") String signatureUUID);

    /**
     * 根据人员id下载人员签章
     *
     * @param personId
     */
    @ApiOperation(httpMethod = "GET", value = "根据人员id下载人员签章")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "personId", value = "人员id", dataType = "Long", dataTypeClass = Long.class)
    })
    @GetMapping(value = "/downloadSignatureByPersonId")
    ResponseData<SignatureResponse> getDownloadSignatureByPersonId(@RequestParam("personId") Long personId);

    /**
     * 人员信息导入
     *
     * @param file
     * @param organizationId
     * @param internal
     * @return
     * @throws IOException
     */
    @ApiOperation(httpMethod = "POST", value = "人员信息导入", notes = "导入项目人员时一定要传入projectId；如果是企业人员导入，则选择true，反之项目人员选择false；")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "organizationId", value = "组织id", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(paramType = "query", name = "projectId", value = "项目id", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(paramType = "query", name = "internal", value = "是否企业人员", dataType = "Boolean", allowableValues = "true, false", dataTypeClass = Boolean.class),
    })
    @PostMapping(value = "/uploadPerson", consumes = "multipart/form-data")
    ResponseData<UploadPersonTemplateValidateResponse> postUploadPerson(@RequestPart("file") MultipartFile file,
                                                                        @RequestParam("organizationId") Long organizationId,
                                                                        @RequestParam(value = "projectId", required = false) Long projectId,
                                                                        @RequestParam("internal") boolean internal) throws IOException;

    /**
     * 确认校验交过并导入数据
     *
     * @param validateId
     * @return
     */
    @ApiOperation(httpMethod = "POST", value = "确认校验交过并导入数据")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "validateId", value = "校验id", dataType = "String", dataTypeClass = String.class),
    })
    @PostMapping(value = "/confirmValidateAndSubmit")
    ResponseData<UploadPersonTemplateValidateResponse> postConfirmValidateAndSubmit(@RequestParam("validateId") String validateId);

    /**
     * 从iMIS同步人员照片base64
     *
     * @param referencePersonId
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "从iMIS同步人员照片base64")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "referencePersonId", value = "ERP人员id", dataType = "Long", dataTypeClass = Long.class),
    })
    @GetMapping(value = "/copyProfileImageBase64FromImis")
    ResponseData<String> getCopyProfileImageBase64FromImis(@RequestParam("referencePersonId") Long referencePersonId);

    /**
     * 从iMIS系统同步数据
     *
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "从iMIS系统同步数据")
    @GetMapping(value = "/syncFromImis")
    ResponseData<Boolean> getSyncFromImis();

    /**
     * 开启定时同步任务
     *
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "开启定时同步任务")
    @GetMapping(value = "/startScheduleSync")
    ResponseData<Boolean> getStartScheduleSync();

    /**
     * 关闭定时同步任务
     *
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "关闭定时同步任务")
    @GetMapping(value = "/endScheduleSync")
    ResponseData<Boolean> getEndScheduleSync();
}
